package com.bishe.demo.utils;

import com.bishe.demo.pojo.vo.Status;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;

@Component
public class Judge {


    public static Status judge(String commodityName, Integer commodityNumber,
                  String commodityCategory,
                  Integer commodityCost, Integer commodityPrice){
        Status status = new Status();
        System.out.println(status==null);

        if (commodityNumber==null||commodityCost==null||commodityPrice==null){

            status.setMsg("数字不能为空！");
            status.setCode(false);
            return status;
        }


        if (StringUtils.isBlank(commodityName)
                ||StringUtils.isBlank(Integer.toString(commodityNumber))
                ||StringUtils.isBlank(commodityCategory)
                ||StringUtils.isBlank(Integer.toString(commodityCost))
                ||StringUtils.isBlank(Integer.toString(commodityPrice))){
            status.setMsg("商品信息不能为空！");
            status.setCode(false);
            return status;
        }
        if (commodityCost<=0){
            status.setMsg("请输入合法进价！");
            status.setCode(false);
            return status;
        }
        if (commodityPrice<=0){
            status.setMsg("请输入合法售价！");
            status.setCode(false);
            return status;
        }
        if (commodityNumber<=0){
            status.setMsg("请输入合法数量！");
            status.setCode(false);
            return status;
        }

        status.setMsg("成功");
        status.setCode(true);
        return status;
    }
}
